<!--
	/*
		Voodoo Validator
		www.voodoovalidator.com
	*/
	
	/*
		For help: admin@voodoovalidator.com
	*/
	
	/*
		This application was developed originally by 
		Robbie Vasquez - www.robbievasquez.com
		Casey McLaughlin - www.caseymclaughlin.com
	*/
	
	/*
		BIRTHDAY: June 1st, 2009
		LAST MODIFIED: 08/12/2010
		BY: Robbie Vasquez
	*/
-->

<!--
	jQuery must be included.  This version is using jQuery 1.4
	Even though jQuery is called into play on voodoovalidator.php, 
	it does not affect this file or others that are generated into it.
	
	This script opens directories when an <h3> element is clicked.
	
	The PHP variables $sans_slash and $path come from the file
	that includes this script, validate_continue.php
	
	$sans_slash is the full path of the directory (excluding the
	root directory) with the '/' marks removed. Since the $sans_slash
	value is coming from the class value of the <h3> elements, the '/'
	was causing a lot of problems. So, $sans_slash removes the '/'
	marks in the PHP script and the <h3> element keeps a unique class.
	The class is used only to differentiate between the directories
	for this script to act.
	
	The PHP value $path needs to get to the PHP script in validate_continue.php
	so the directory clicked will be opened and displayed, and
	so directories within it can be prepared.
-->

<!-- make sure jQuery is included -->
<script type="text/javascript" src="/voodoo_scripts/jquery.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		
		// This must be the complete path to the root of the website.
		// $path is added on to get as deep in to the directories as needed.
		// $path comes from validate_continue.php since this file
		// is called with a require() in validate_continue.php
		// Include trailing slash!!!
		var the_url = 'http://www.example.com/<?php echo $path; ?>/';
		
		// $sans_slash ensures that each <h3> element has a unique class
		// The variable comes from validate_continue.php
		$('h3.directory_<?php echo $sans_slash; ?>').click(function() {
			if($(this).attr('class') == 'directory_<?php echo $sans_slash; ?>')
			{
				// 'dir' with $path is the full path to the directory from
				// the root of the server to the directory itself
				var dir = '<?php echo $path;?>/' + $(this).attr('id');
				
				// The 'id' of the <h3> element matches the 'id' of an <li> element
				// set up by validate_continue.php
				// The <li> with an 'id' value matching the $sans_slash value
				// will be filled with the resulting output from validate_continue.php
				var id = $(this).attr('id');
				$(this).removeClass('directory_<?php echo $sans_slash; ?>').addClass('clicked_<?php echo $sans_slash; ?>');
				$('li#<?php echo $sans_slash; ?>' + id).load('/voodoo_scripts/validate_continue.php', 'dir=' + dir);
			}
		});
		
		// validate_continue.php created a set of <li> elements, all with a class 'file'
		// if they are holding a file rather than a directory.
		// Those <li> elements hold the name of the file as 'id' values.
		// Any <li> element of class 'file' provides information to be used by the
		// validating file, validate_w3c_v4.php
		$.each($('li.file'), function() {
			var the_file_name = the_url + $(this).attr('id');
			var name = $(this).attr('id');
			$(this).removeClass('file').addClass('checked');
			$(this).load('/voodoo_scripts/validate_w3c_v4.php', 'url=' + the_file_name + '&file=' + name);
		});
		
	});
</script>